home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- """Fixer for callable().
-
- This converts callable(obj) into hasattr(obj, '__call__')."""
- from import pytree
- from import fixer_base
- from fixer_util import Call, Name, String
-
- class FixCallable(fixer_base.BaseFix):
- PATTERN = "\n power< 'callable'\n trailer< lpar='('\n ( not(arglist | argument<any '=' any>) func=any\n | func=arglist<(not argument<any '=' any>) any ','> )\n rpar=')' >\n after=any*\n >\n "
-
- def transform(self, node, results):
- func = results['func']
- args = [
- func.clone(),
- String(', '),
- String("'__call__'")]
- return Call(Name('hasattr'), args, prefix = node.get_prefix())
-
-
-